/**
 * @Author：ming
 * @Date：2023/9/30 10:31 PM
 * @Filename：Lc73
 */

import java.util.ArrayList;

/**
 * @author ming
 */
public class Lc73 {
    public void setZeroes(int[][] matrix) {

        ArrayList<int[]> list = new ArrayList<>();

        int l = matrix.length;
        int r = matrix[0].length;
        for (int i = 0; i < l; i++) {
            for (int j = 0; j < r; j++) {
                if(matrix[i][j]==0){
                    int[] a = {i, j};
                    list.add(a);
                }
            }
        }

        for (int[] a : list) {
            int i = a[0];
            int j = a[1];

            setZero(matrix,i,j);
        }


    }

    public void setZero(int[][] matrix,int r,int c){
        int l = matrix.length;
        int f = matrix[0].length;
        for (int i = 0; i < l; i++) {
            if(matrix[i][c]!=0){
                matrix[i][c]=0;
            }
        }

        for (int i = 0; i < f; i++) {
            if(matrix[r][i]!=0){
                matrix[r][i]=0;
            }
        }

    }

}
